Local Test Cases:
# there can be no spaces on either side of the equal sign, before the error has been out here
yesterday= ' date-d last-day +%y-%m-%d '
echo $yesterday
curday= ' Date +%y-%m-%d '
echo $curday
echo "Now time: ' Date ' +%y%m%d%T '"
Get the date of the dayDate +%y-%m-%dOutput: 2011-07-28Assigns the current date to a date variabledate=$ (Date +%y%m%d)Sometimes we need to use dates before or after today, so we can use the-D parameter of dateGet Tomorrow's dateDate-d Next-day
use the shell in Linux to get yesterday, tomorrow or many days before the date time -- A- , the: -:xxblogjava-Expert Area Original http://www.blogjava.net/xzclog/archive/2015/12/08/428555.htmlTheme Shell Original address:
Use the shell in Linux to get yesterday, tomorrow, or many days ago:In Linux, the man date-d parameter is relatively vague, the following examples further illustrate:#-D,--date=string display time described by STRING, not ' now '[Email protected]
Name: Date
Permission: All Users
Usage: Date [-u] [-D datestr] [-s datestr] [-- UTC] [-- Universal]
[-- Date = datestr] [-- set = datestr] [-- help] [-- version] [+ format]
[Mmddhhmm [[CC] YY] [. SS]
Note: date can be used to display or set the date
Name: DatePermission: All UsersUsage: date [-u] [-D datestr] [-s datestr] [-- UTC] [-- Universal] [-- date = datestr] [-- set = datestr] [-- help] [-- version] [+ format] [mmddhhmm [[CC] YY] [. SS]Note: date can be used to display or set the date
Get the date of the dayDate +%y-%m-%dOutput: 2011-07-28Assigns the current date to a date variabledate=$ (Date +%y%m%d)Sometimes we need to use dates before or after today, so we can use the-D parameter of dateGet Tomorrow's dateDate-d Next-day
Get the date of the dayDate +%y-%m-%dOutput: 2011-07-28Assigns the current date to a date variabledate=$ (Date +%y%m%d)Sometimes we need to use dates before or after today, so we can use the-D parameter of dateGet Tomorrow's dateDate-d Next-day
Shell obtains the system time and returns the date + % Y-% m-% d of the current day. output:, assign the value of myDate to my variable $ (date + % Y % m % d) assign the current DATE to the DATE variable date $ (DATE + % Y % m % d). sometimes we
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.